import type { App } from "vue";
import { setupTailwindcss } from "./tailwindcss";
import _ from 'lodash'
import setupElementPlus from "./elementPlus"
import setupEcharts from "./echarts";
import setupPinia from "./pinia";
import setupDataV from "./dataV";
//初始化所有插件
export function setupPlugins(app:App){
    autoRegisterComponent(app)
    setupTailwindcss()
    setupElementPlus(app)
    setupEcharts(app)
    setupPinia(app)
    setupDataV(app)
}

//自动注册全局组件
function autoRegisterComponent(app:App){
    const components = import.meta.glob('../components/form/*.vue',{ eager: true }) as Record<string,any>
    Object.keys(components).forEach(key=>{
        const name  = key.split('/').pop()?.split('.').shift() as string;
     
        app.component(_.camelCase(name),components[key].default)
    })
}